<template>
  <div class="homework">
    <el-button
      class="btn-back"
      size="small"
      type="custom"
      @click="flag = 1"
      v-show="flag == 2"
      >返回列表</el-button
    >
    <HomeworkList v-if="flag == 1" />
    <HomeworkDetail v-if="flag == 2" :row="row" />
  </div>
</template>
<script>
export default {
  components: {
    HomeworkList: () => import('./index.vue'),
    HomeworkDetail: () => import('./HomeworkDetail.vue'),
  },
  data() {
    return {
      flag: 1,
      row: {},
    }
  },
  mounted() {
    this.$bus.$on('changeFlag', (flag, row) => {
      this.flag = flag
      this.row = row
    })
  },
  beforeDestroy() {
    this.$bus.$off('changeFlag')
  },
}
</script>
<style scoped lang="scss">
.homework {
  position: relative;
  .btn-back {
    position: absolute;
    right: 10px;
    top: 0px;
  }
}
</style>